<?php
require("phpsqlajax_dbinfo.php");

function parseToXML($htmlStr)
{
	$xmlStr=str_replace('<','&lt;',$htmlStr);
	$xmlStr=str_replace('>','&gt;',$xmlStr);
	$xmlStr=str_replace('"','&quot;',$xmlStr);
	$xmlStr=str_replace("'",'&#39;',$xmlStr);
	$xmlStr=str_replace("&",'&amp;',$xmlStr);
	return $xmlStr;
}

// Select all the rows in the markers table
$query = "SELECT * FROM markers";
$result = mysql_query($query);
if (!$result) {
	die('Invalid query: ' . mysql_error());
}

//header("Content-type: text/xml");
header('Content-Type: text/xml;');
header('Cache-Control', 'no-cache');
header('Content-type: application/xml; encoding="ISO-8859-1"');
echo '<?xml version="1.0" encoding="ISO-8859-1"?>' . "\n";

// Start XML file, echo parent node
echo '<markers>';

// Iterate through the rows, printing XML nodes for each
while ($row = @mysql_fetch_assoc($result)){
	// ADD TO XML DOCUMENT NODE
	echo '<marker ';
	echo 'id="' . parseToXML($row['id']) . '" ';
	echo 'name="' . parseToXML($row['name']) . '" ';
	echo 'address="' . parseToXML($row['address']) . '" ';
	echo 'lat="' . $row['lat'] . '" ';
	echo 'lng="' . $row['lng'] . '" ';
	echo 'type="' . $row['type'] . '" ';
	echo 'fone="' . $row['fone'] . '" ';
	echo 'city="' . $row['city'] . '" ';
	echo 'sector="' .parseToXML($row['sector']). '" ';
	echo 'state="' . $row['state'] . '" ';
	echo 'cep="' . $row['cep'] . '" ';
	echo 'cost="' . $row['cost'] . '" ';
	echo 'payment="' . $row['payment'] . '" ';
	echo 'number="' . $row['number'] . '" ';
	echo 'image="' . $row['image'] . '" ';
	echo 'fk_client="' . $row['fk_client'] . '" ';
	echo '/>';
}

// End XML file
echo '</markers>';

?>
